package com.block.source.factory;

import com.block.common.util.ApplicationContextUtil;
import com.block.source.enums.ReceiveTypeEnum;
import com.block.source.service.ISourceReceiveService;
import com.block.source.service.receive.*;

import java.util.HashMap;
import java.util.Map;

public class SourceApiFactory {

    private static final Map<String, Class<? extends ISourceReceiveService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(ReceiveTypeEnum.DEFAULT.getValue(), DefaultReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.SOURCECOMMON.getValue(), CommonReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.JXYQ.getValue(), JiXiangYouQianReceiveService.class);

    }

    public static ISourceReceiveService getService(String pushType){
        if (serviceMap.containsKey(pushType)){
            Class<? extends ISourceReceiveService> aClass = serviceMap.get(pushType);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }

}
